% input encoding
%\RequirePackage[utf8]{inputenc}

% new german spelling
\RequirePackage[english,ngerman]{babel}

% choose font
\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}

% KomaOptions
\ifdefined\KOMAoptions%
	\KOMAoptions{%
 	 parskip=full,%
  	fontsize=12pt}%
\fi

% color and images
\RequirePackage{xcolor}
\RequirePackage{graphicx}

% set special behaviour for hyperlinks in pdfs
\RequirePackage{hyperref}
\hypersetup{%
	breaklinks=true, pdfencoding=auto%
}
\g@addto@macro\UrlBreaks
{%
    \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
    \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
    \do\u\do\v\do\w\do\x\do\y\do\z\do\&\do\1\do\2\do\3%
    \do\4\do\5\do\6\do\7\do\8\do\9\do\0\do\/\do\.%
}
\g@addto@macro\UrlSpecials
{%
    \do\/{\mbox{\UrlFont/}\hskip 0pt plus 10pt}%
}

\Urlmuskip=0mu plus 1mu\relax

\AtBeginDocument{%
	\setcounter{biburlucpenalty}{1}  %break URL after uppercase character
	\setcounter{biburlnumpenalty}{1} %break URL after number
	\setcounter{biburllcpenalty}{1}  %break URL after lowercase character
}

\RequirePackage[backend=biber,maxbibnames=99]{biblatex}


\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{physics}
\RequirePackage{tcolorbox}
\RequirePackage{cancel}
\RequirePackage{svg}
\RequirePackage{multicol}
\RequirePackage{gensymb}
\RequirePackage{mathtools}
\RequirePackage{enumitem}
\RequirePackage{float}
\RequirePackage{textcomp}
\RequirePackage{pgfplots}
\RequirePackage{needspace}
\RequirePackage{ifluatex}
\RequirePackage{icomma}
\RequirePackage{xstring}
\RequirePackage{etoolbox}
\RequirePackage{chemformula}
\RequirePackage{chemmacros}
\RequirePackage{xspace}
\RequirePackage{chemfig}
\RequirePackage{booktabs}
\RequirePackage{makecell}
\RequirePackage{csquotes}
\RequirePackage{braket}

\chemsetup{modules = all}
\setchemfig{%
	atom sep = 2em,
	double bond sep = 3pt,
	cram width = 1ex,
}


\ifluatex
	\RequirePackage{fontspec}
	% hyphenate everything regardless whether there are any hyphens in it
	\directlua{require('hyphenateAll')}
\else
	\RequirePackage[utf8]{inputenc}
\fi

\newcommand{\italic}[1]{\begin{emph}#1\end{emph}}
\newcommand{\keyword}[1]{\textbf{\textcolor{green}{#1}}}
\newcommand{\constant}[2]{\italic{#1} $#2$}
\newcommand{\defEq}{\vcentcolon =}
\newcommand{\jhat}{\hat\jmath}
\newcommand{\exclEq}{\overset{!}{=}}
\newcommand{\bitem}[1]{\item\textbf{#1}~-~\hspace{-1.5mm}}

\newenvironment{important}[1]{\begin{tcolorbox}[width=\textwidth,colback={white},title={\textbf{#1}},colbacktitle=red,coltitle=black]} {\end{tcolorbox}}

\newenvironment{warning}[1]{\begin{tcolorbox}[width=\textwidth,colback={white},title={\textbf{#1}},colbacktitle=yellow,coltitle=black]} {\end{tcolorbox}}
\newenvironment{info}[1]{\begin{tcolorbox}[width=\textwidth,colback={white},title={\textbf{#1}},colbacktitle=cyan,coltitle=black]} {\end{tcolorbox}}

\newenvironment{image}[1][H]{\begin{figure}[#1]\centering}{\end{figure}}

\DeclareRobustCommand{\unit}[2][]{%
	\ifmmode%
		\ifstrempty{#1}{%
			\mathrm{#2}%
		}{%
			\mathrm{#1\,#2}%
		}%
	\else%
		$\unit[#1]{#2}$%
	\fi%
}

\AtBeginDocument{%
	\let\refCopy\ref%
	\renewrobustcmd{\ref}[1]{%
		\IfBeginWith{#1}{eq:}{%
			{\upshape (\refCopy{#1})}%
		}{%
			\refCopy{#1}%
		}%
	}%
}%